# 需求：将小于房子剩余面积的家具摆放到房子中
class Furniture:
    name = ''
    area = 0

    def __init__(self, name, area):
        self.name = name
        self.area = area

    def __str__(self):
        return f'家具{self.name},面积{self.area}'


class Home:
    def __init__(self, area):
        self.area = area
        self.free_area = area
        self.furniture_list = []

    def __str__(self):
        return f'房子总面积{self.area},剩余面积{self.free_area},家具有{self.furniture_list}'

    def add_furniture(self, item: Furniture):
        if self.free_area >= item.area:
            self.furniture_list.append(item.name)
            self.free_area -= item.area
        else:
            print("面积不够了")


home = Home(100)
print(home)
bed = Furniture('床', 10)
sofa = Furniture('沙发', 5)
haha = Furniture('哈哈', 500)
home.add_furniture(bed)
print(home)
home.add_furniture(sofa)
print(home)
home.add_furniture(haha)
print(home)
